//
//  TableViewController.m
//  GuiJuWo
//
//  Created by chenguibang on 16/3/29.
//  Copyright © 2016年 chenguibang. All rights reserved.
//

#import "TestVC.h"
#import "LoginC.h"
#import "PgyUtil.h"
#import "BaseTabBarControler.h"
#import "UIViewGBExtentTest.h"
#import "WebViewJSUtil.h"

@interface TestVC (){
    NSArray * data;
}

@end

@implementation TestVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    data = @[@"返回",@"打开摇动蒲公英",@"模拟发送报告",@"登录",@"tabVC",@"UIViewGBExtentTest",@"JSUtil"];

    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return data.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell= nil;
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"aaa"];
    }
    cell.textLabel.text = data[indexPath.row];

    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *title = cell.textLabel.text;
    if ([title isEqualToString:@"打开摇动蒲公英"]) {
        [PgyUtil setEnableFeedback:YES];
    }else if ([title isEqualToString:@"登录"]) {
        LoginC *login = [[LoginC alloc]init];
//        login.isPresetVC = YES;
//        login.hidesBottomBarWhenPushed = YES;
//        [self presentViewController:login animated:YES completion:^{
//            
//        }];
        [self.navigationController pushViewController:login animated:YES];
    }
    else if ([title isEqualToString:@"模拟发送报告"]) {
      
        @try {
            NSArray *array = [NSArray arrayWithObjects:@"", nil];
            NSString *value = [array objectAtIndex:10];
            
            NSLog(@"The value at index 10 is: %@", value);
        } @catch (NSException *exception) {
            [PgyUtil reportException:exception];
        } @finally {
            
        }

    }
    else if ([title isEqualToString:@"返回"]) {
        [self.navigationController popViewControllerAnimated:YES];
    }
    else if ([title isEqualToString:@"tabVC"]) {
        BaseTabBarControler *login = [[BaseTabBarControler alloc]init];
        [self.navigationController pushViewController:login animated:YES];
        
    } else if ([title isEqualToString:@"UIViewGBExtentTest"]) {
        UIViewGBExtentTest *login = [[UIViewGBExtentTest alloc]init];
        [self.navigationController pushViewController:login animated:YES];
        
    }
    
    else if ([title isEqualToString:@"JSUtil"]) {
       
//        [WebViewJSUtil splitUrl:@"function:login&paramters:jsonstring"];
        
        NSDictionary *dict  = [NSDictionary dictionaryWithObjectsAndKeys:@"function",@"function" ,nil];
        
        NSString *sdd = [dict mj_JSONString];
        
        
       NSString *strs = [WebViewJSUtil getFunctionName:sdd];
        
//         NSString *pp = [WebViewJSUtil getParamters:@"function:functionName&paramters:jsonstring"];
        NSLog(@"犯法:%@  canshu ",strs);
    }
    
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
